<div class=" alert-success "><?php echo $this->Session->flash(); ?></div>
<div class="bs-example"  >
   <div id="response"> </div>
	<div class="menu-top">
		<div class="title-note">
		<h4> <i class="fa fa-question">&nbsp;</i><?php echo __('Câu hỏi'); ?></h4>
		
		</div>
		<div class="option-action">
			<a href="/questions/add"><button type="button" class="btn btn-primary btn-sm">Thêm mới</button></a>&nbsp;
			<a style="padding-right:5px;" href="/questions/deleteAllMember"><button type="button" class="btn btn-danger btn-sm">Hủy người tham gia</button></a>
			<a style="padding-right:5px;" href="/questions/deleteAllQA"><button type="button" class="btn btn-danger btn-sm">Hủy kết quả trả lời</button></a>
			<?php if($key!=1){ ?><a style="padding-right:5px;" href="/questions/finish"><button type="button" class="btn btn-danger btn-sm">Kết thúc hội thảo</button></a><?php } ?>
		</div>
	</div>
	
	<table  class="table table-striped table-bordered">
	<tr>		
			<th width="5%">STT</th>
			<th width="40%">Câu hỏi</th>
			<th >Ngày bắt đầu</th>		
			<th >Ngày kết thúc</th>
			<th width="10%">Trạng thái</th>
			<?php if($key !=1){ ?><th width="8%">Sắp xếp</th><?php }?>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	<?php
	$n=1;
	$count = count($questions);
	foreach ($questions as $question): ?>
	<tr>
		
		<td align="center"><?php echo $n;?></td>
		<td>                
                <a href="/answers/add/<?php echo $question['Question']['id'];?>"><?php echo $question['Question']['name'];?></a>
                </td>		
		<td><?php echo h(date("d-m-Y H:s:i",strtotime($question['Question']['time_start']))); ?>&nbsp;</td>
		<td><?php echo h(date("d-m-Y H:s:i",strtotime($question['Question']['time_end']))); ?>&nbsp;</td>
		
		
		<td align="center"><?php 
                    if($question['Question']['status']==1){
                       echo $this->Html->link(__(''), array('action' => 'block', $question['Question']['id']),array('title'=>'Block câu hỏi','class'=>'fa fa-check','style'=>'color:#4cae4c;font-size:18px;'));
                    }elseif($question['Question']['status']==0){
                        echo $this->Html->link(__(''), array('action' => 'open', $question['Question']['id']),array('title'=>'Open câu hỏi','class'=>'fa fa-times','style'=>'color:red;font-size:18px;'));
                    }else{
                        echo $this->Html->link(__(''), array('action' => 'open', $question['Question']['id']),array('title'=>'Open câu hỏi','class'=>'fa fa-refresh','style'=>'color:#eea236;font-size:18px;'));
                    }
                ?>
                
                </td>	<?php if($key !=1){ ?>
                <td align="center">
					<?php 
					if($n==1){?>
						<a  href="/questions/down/<?php echo $question['Question']['id'].'/'.$question['Question']['order']?>"> <i style="color:#000;font-size:18px;" class="fa fa-arrow-down "></i></a> 
					<?php }elseif($n == $count){?>
					 <a href="/questions/up/<?php echo $question['Question']['id'].'/'.$question['Question']['order']?>"> <i style="color:#000;font-size:18px;" class=" fa fa-arrow-up"></i></a> 
					<?php }else{?>
					 <a href="/questions/down/<?php echo $question['Question']['id'].'/'.$question['Question']['order']?>"> <i style="color:#000;font-size:18px;" class="fa fa-arrow-down "></i></a> 
				     <a href="/questions/up/<?php echo $question['Question']['id'].'/'.$question['Question']['order']?>"> <i style="color:#000;font-size:18px;" class=" fa fa-arrow-up"></i></a> 
					<?php } ?>
                  
                </td>
				<?php }?>
		<td class="actions">
			<?php 
                        if($key!=1){
						if($question['Question']['question_end']==0){
                         echo $this->Html->link(__(''), array('action' => 'end', $question['Question']['id']),array('title'=>'Chọn làm câu cuối','class'=>'fa fa-play','style'=>'color:#4cae4c'));
                        }else{
                               echo $this->Html->link(__(''), array('action' => 'enddel', $question['Question']['id']),array('title'=>'Hủy câu cuối','class'=>'fa fa-power-off','style'=>'color:red'));
                        }
						}
                        ?>
			<?php echo $this->Html->link(__(''), array('action' => 'edit', $question['Question']['id']),array('title'=>'Sửa câu hỏi','class'=>'fa fa-pencil-square-o')); ?>
			<?php echo $this->Form->postLink(__(''), 
					array('action' => 'delete', $question['Question']['id']),
					array('title'=>'Xóa câu hỏi','class'=>'fa  fa-trash-o','style'=>'color:#000'), 
					__('Bạn muốn xóa câu hỏi? ', 
					$question['Question']['id'])); ?>
		
		</td>
	</tr>
<?php $n++;endforeach; ?>
	</table>
    <?php echo $this->element('pagination');?>
</div>

